from app import db

class Table(db.Model):
    __tablename__ = 'detailTable'
    
    id = db.Column(db.Integer, primary_key=True)
    mid = db.Column(db.String(20), nullable=False)
    table_content = db.Column(db.Text(), nullable=False)
    created_at = db.Column(db.DateTime, default=db.func.current_timestamp())

    def to_dict(self):
        """转换为字典，方便接口返回"""
        return {
            'id': self.id,
            'mid': self.mid,
            'table_content': self.table_content,
            'created_at': self.created_at.isoformat()
        }
